package demo;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

/**
 * @author ：黄淼淳
 * @date ：2021/12/19 0:25
 * @description：阻塞队列
 */
public class BlokingQueueDemo {
    public static void main(String[] args) {
        /**
         * 阻塞队列
         * 有界限值，在实例化的时候必须给出初始界限值
         * 当值的个数超过界限值的时候将会抛出-》java.lang.IllegalStateException: Queue full
         *
         */
        BlockingQueue<Integer> block = new ArrayBlockingQueue<>(3);
       /* block.add(1);
        block.add(2);*/
        block.offer(1);
        block.offer(2);
        block.offer(2);
        System.out.println(block.offer(2));
        System.out.println(block.poll());
    }
}
